1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
<script>
import { f, s, sats } from '$lib/utils';
import { animatedRate } from '$lib/store';
import { Icon } from '$comp';
import { t } from '$lib/translations';
import { sign, send } from '$lib/nostr';
export let data;
let events, user, subject, rates, src, text;
$: ({ events, user, rates, subject, src, text } = data);
$: ({ currency, username: n, display } = subject);
$: username = n.length > 60 ? n.substr(0, 6) : display || n;
let follow = async () => {
user.follows.push(['p', subject.pubkey, 'wss://nostr.coinos.io', subject.username]);
update();
};
let unfollow = async () => {
user.follows.splice(
user.follows.findIndex((t) => t[1] === subject.pubkey),
1
);
update();
};
let update = async () => {
let event = {
pubkey: user.pubkey,
created_at: Math.floor(Date.now() / 1000),
kind: 3,
content: '',
tags: user.follows
};
await sign({ event, user });
await send(event);
user.follows = user.follows;
};
$: following = !!user?.follows.find((t) => t.includes(subject.pubkey));
let hideBio = true;
let toggleBio = () => (hideBio = false);
</script>
<div class="container mx-auto w-full px-4 mb-4 flex flex-wrap lg:flex-nowrap space-y-5">
<div class="hidden lg:block w-[240px] lg:mr-10" />
<div class="w-[240px] lg:absolute space-y-5 left-20 mx-auto lg:mr-10">
<h1 class="text-3xl font-bold text-center mx-auto">{display || username}</h1>
{#if subject.address}
<div
class="text-secondary mx-auto text-center lg:text-left lg:mx-0"
class:line-clamp-3={hideBio}
on:click={toggleBio}
>
{subject.address}
</div>
{/if}
<div class="flex justify-around">
<a href={`/${subject.pubkey}/follows`}
><b>{subject.follows.length}</b>
<span class="text-secondary">{$t('user.following')}</span></a
>
<a href={`/${subject.pubkey}/followers`}
><b>{subject.followers.length}</b>
<span class="text-secondary">{$t('user.followers')}</span></a
>
</div>
<div class="flex flex-wrap gap-2 w-full">
{#if user && user.username !== subject.username && subject.pubkey}
{#if following}
<div class="w-full flex">
<button
class="rounded-full border py-3 px-6 font-bold hover:opacity-80 flex w-60 bg-black text-white"
on:click={unfollow}
>
<div class="mx-auto flex">
<Icon icon={'profile'} style="my-auto h-6 mr-2 invert" />
<div class="my-auto">{$t('user.following')}</div>
</div>
</button>
</div>
{:else}
<div class="w-full flex">
<button
class="rounded-full border py-3 px-6 font-bold hover:opacity-80 flex w-60"
on:click={follow}
>
<div class="mx-auto flex">
<Icon icon={'profile'} style="my-auto h-6 mr-2" />
<div class="my-auto">{$t('user.follow')}</div>
</div>
</button>
</div>
{/if}
{/if}
{#if !subject.anon && subject.username !== user?.username}
<div class="w-full flex">
<a
href={user ? `/send/${subject.username}` : `/${subject.username}/receive`}
class="mx-auto"
>
<button class="rounded-full border py-3 px-6 font-bold hover:opacity-80 flex w-60">
<div class="mx-auto flex">
<Icon icon="send" style="mr-2" />
<div class="mt-1">{$t('user.pay')}</div>
</div>
</button>
</a>
</div>
{/if}
{#if user && user.username !== subject.username && subject.pubkey}
<div class="w-full flex">
<a href={`/${subject.username}/messages`} class="mx-auto">
<button class="rounded-full border py-3 px-6 font-bold hover:opacity-80 flex w-60">
<div class="mx-auto flex">
<Icon icon="support" style="mr-2 my-auto" />
<div class="mt-1 my-auto">{$t('user.message')}</div>
</div>
</button>
</a>
</div>
{/if}
</div>
</div>
<div class="w-full">
<div class="mx-auto space-y-5 lg:max-w-lg xl:max-w-2xl">
<slot />
</div>
</div>
</div>
{#if currency && !isNaN($animatedRate)}
<div class="flex fixed w-full px-4 bg-white py-2 bottom-0 bg-opacity-90 tabular-nums">
<div class="text-secondary flex mr-auto">
<div class="flex mr-1">
<div class="my-auto mr-1">1</div>
<img src="/images/bitcoin.svg" class="w-5 my-auto" alt="Bitcoin" />
</div>
<div>= {f($animatedRate, currency)}</div>
</div>
<div class="text-secondary flex ml-auto">
<div class="flex">
<div class="mr-1">⚡️{s((1 * sats) / $animatedRate)} =</div>
<div>{f(1, currency)}</div>
</div>
</div>
</div>
{/if}
|